package com.pro.xwt.common.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.pro.xwt.common.mapper.DFileMapper;
import com.pro.xwt.common.mapper.DFolderMapper;
import com.pro.xwt.common.model.DFile;
import com.pro.xwt.common.model.DFolder;
import com.pro.xwt.common.service.DFolderService;

@Service("dFolderService")
public class DFolderServiceImpl extends AbstractService<DFolder, String> implements DFolderService {
	@Autowired
	DFolderMapper dFolderMapper;
	@Autowired
	DFileMapper dFileMapper;

	public List<DFolder> findByProjId(String id) {
		// TODO Auto-generated method stub
		return dFolderMapper.findByProjId(id);
	}

	public List<DFolder> findSubFoldByParentId(String id) {
		return dFolderMapper.findSubFoldByParentId(id);
	}

	public int updateTime(Date date, String id) {
		DFolder dFolder = new DFolder();
		dFolder.setId(id);
		dFolder.setUpdateTime(date);

		return dFolderMapper.update(dFolder);
	}

	@Override
	public int updateSize(Long size, String id) {
		return dFolderMapper.updateSize(size, id);
	}

	@Override
	public int deleteFileAndFolder(String id) {
		Map<String,Object> map = new HashMap<>();
		int flag = dFolderMapper.deleteById(id);
		/*DFile dFiles = dFileMapper.findByCondition(map);
		flag = dFileMapper.deleteByfolderId(id);
		flag = dFolderMapper.deleteByParentFolderId(id);*/
		return flag;
		}

}
